/** 仓库 */
var updatearea = require("./updatearea"), combobox = require("../base/combobox.js");
cc.Class({
    extends: cc.Component,

    properties: {
        /** 升级对象 */
        upObj:updatearea,
        /** 元素预制件 */
        pf_item:cc.Prefab,
        /** 仓库节点 */
        nd_storage:cc.Node,
        /** 英雄背包 */
        nd_bag:cc.Node,
        /** 英雄列表 */
        cb_herolist:combobox,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.upObj.showInfo(5);

        this.nd_storage.removeAllChildren();
        let bag = App.U.city[App.cid].bag;
        for(let i=0;i<bag.length;i++){
            let obj = cc.instantiate(this.pf_item);
            obj.getChildByName("sp_pic").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(App.path + "troops/" + ct.race + "/" + k + ".png");
            obj.getChildByName("txt_num").getComponent(cc.Label).string = bag[i].num;
            obj.parent = this.nd_storage;
        }
        for(let j=0;j<App.U.hero.length;j++){
            if(App.U.hero[j].map[0] == App.U.uid && App.U.hero[j].map[1] == App.cid){
                this.cb_herolist.d_dataV.push(App.U.hero[j].heroname);
            }
        }
        if(this.cb_herolist.d_dataV.length > 1){
            this.cb_herolist.selIndex = 1;
            this.cb_herolist.databind();
        }
        this.cb_herolist.node.on("combo", function(ev){
            console.log("cb_herolist", this.cb_herolist.selIndex);
        }, this);
    },

    /** 显示英雄背包 */
    heroBag(hid){
        this.nd_bag.removeAllChildren();
    },

    /** 物品开始移动 */
    itemTouchBegin(ev){

    },
    /** 物品移动 */
    itemTouchMove(ev){

    },
    /** 物品结束移动 */
    itemTouchEnd(ev){

    },
    // update (dt) {},
});
